<?php

	include("config.php");
    include(INCLUDEDIR."core.php");
	if(session_get("logged")=="admin") {
		header("location: main.php");	
	}
	
	$tpl = new Plantilla();
	$tpl->setPlantilla("tpl.login.html");
	$tpl->prepare();
	
	if($_POST['login'] ||  $_POST['password']) {
		$usuario = new Administrador();
		$login = $_POST['login'];
		$password = $_POST['password'];
		if($usuario->validate($login,$password)) {
			$usuario->login($login);
			header("location: main.php");
			exit();
		}
		$tpl->setError("No se pudo identificar",true);
	}
	
	
	
	if($_POST) foreach($_POST as $k => $v) $tpl->assign($k,$v);
	$tpl->newBlock("FORMULARIO");
	$tpl->Mostrar();
	

?>